package com.steven.ourcontest.information.viewmodel

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.steven.ourcontest.base.BaseViewModel
import com.steven.ourcontest.information.api.InfoApi
import com.steven.ourcontest.information.bean.IdentifyStatusResponse
import com.steven.ourcontest.information.bean.SchoolList
import com.steven.ourcontest.information.bean.UserDetail
import com.steven.ourcontest.net.EmptyResponse
import com.steven.ourcontest.utils.plusAssign
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.MultipartBody
import okhttp3.RequestBody

class UploadViewModel: BaseViewModel() {
    private val _uploadRes = MutableLiveData<EmptyResponse?>()
    val uploadRes: LiveData<EmptyResponse?>
        get() = _uploadRes

    fun uploadImage(body: RequestBody){
        disposed += InfoApi.instance.uploadCard(body)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe({
                _uploadRes.value = it.result
            }, {
                it.printStackTrace()
            })
    }
}